<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/6/4
 * Time: 16:27
 */
namespace App\Modules\Jobs\Services;
use App\Jobs\CreateTask;
use App\Jobs\Reward;
use App\Jobs\SelfRecomend;
use App\Jobs\SendTemplateMessage;
use App\Jobs\Share;

class JobService {
    /**
     * 创建任务队列
     * @param $param `tasks`数据表对象
     */
    public static function CreateTask($param){
        $delay=0;
        $job = (new CreateTask($param))->onConnection('redis')->delay($delay);
        dispatch($job);
    }

    /**
     * 自荐队列
     * @param $action selfRecomend-自荐，viewRec-查看自荐，adopt-感兴趣
     * @param $param `self_recommendations`数据表对象
     */
    public static function SelfReco($action,$param){
        $delay=0;
        $job = (new SelfRecomend($action,$param))->onConnection('redis')->delay($delay);
        dispatch($job);
    }

    /**
     * 转发队列
     * @param $param `spreads`数据表对象
     */
    public static function Share($param){
        $delay=0;
        $job = (new Share($param))->onConnection('redis')->delay($delay);
        dispatch($job);
    }

    /**
     * 打赏队列
     * @param $param1 `self_reco_suc_chains`表对象数据
     *
     */
    public static function Reward($param1){
        $delay=0;
        $job = (new Reward($param1))->onConnection('redis')->delay($delay);
        dispatch($job);
    }

    public static function sendTemplateMessage($param,$instance){
        $delay=0;
        $job = (new SendTemplateMessage($param,$instance))
            ->onConnection('redis')
            ->delay($delay)
            ->onQueue('sendMsg');
        dispatch($job);
    }
}